package com.rxz.redisdemo.controller;

import com.rxz.redisdemo.entity.Result;
import com.rxz.redisdemo.service.impl.RedisService;
import jakarta.servlet.http.HttpSession;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("rxz")
public class RedisController {

    @Autowired
    private RedisService redisService;

    @PostMapping("/incr")
    public Integer incr(Long id){
        return redisService.incr(id);
    }

    @PostMapping("/send/{phone}")
    public Result send(@PathVariable String phone, HttpSession session){
        return redisService.sendCode(phone,session);
    }

    @PostMapping("/login")
    public Result login(@PathParam("phone") String phone,@PathParam("number") String number,HttpSession session){
        return redisService.login(phone,number,session);
    }
}
